﻿<UserControl x:Class="SubtitleTools.Shell.Toolbar"
			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
			 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
			 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
			 xmlns:Views="clr-namespace:SubtitleTools.Shell"  
			 xmlns:Ctrls="clr-namespace:SubtitleTools.Common.Controls;assembly=SubtitleTools.Common"
			 xmlns:b="clr-namespace:SubtitleTools.Common.Behaviors;assembly=SubtitleTools.Common"
			 xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"              
			 mc:Ignorable="d" FontFamily="Tahoma"
			 d:DesignHeight="63" d:DesignWidth="400">
	<Grid>
		<ToolBar>
			<Button ToolTip="Open a subtitle file" Margin="2">
				<StackPanel HorizontalAlignment="Center" Margin="1">
					<Image Source="Images/open.png" Width="32" Height="32" HorizontalAlignment="Center" />
                    <TextBlock Text="Open Subtitle" HorizontalAlignment="Center" />
				</StackPanel>
				<i:Interaction.Triggers>
					<i:EventTrigger EventName="Click">
						<b:OpenFileDialogBoxBehavior 
									DialogFilterType="Subtitle"
									FileDialogDialogResultCommand="{Binding MainWindowGuiData.OpenedFilePath, Mode=TwoWay}"/>
					</i:EventTrigger>
				</i:Interaction.Triggers>
			</Button>

            <Button ToolTip="Open a movie file" Margin="2">
                <StackPanel HorizontalAlignment="Center" Margin="1">
                    <Image Source="Images/movies.png" Width="32" Height="32" HorizontalAlignment="Center" />
                    <TextBlock Text="Open Media" HorizontalAlignment="Center" />
                </StackPanel>
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <b:OpenFileDialogBoxBehavior 
									DialogFilterType="Movie"
									FileDialogDialogResultCommand="{Binding MainWindowGuiData.MediaFilePath, Mode=TwoWay}"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Button>

            <Separator />

            <Button ToolTip="Open WAV file(s)" Margin="2">
                <StackPanel HorizontalAlignment="Center" Margin="1">
                    <Image Source="Images/voice_chat.png" Width="32" Height="32" HorizontalAlignment="Center" />
                    <TextBlock Text="Open WAV" HorizontalAlignment="Center" />
                </StackPanel>
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <b:OpenFileDialogBoxBehavior 
									DialogFilterType="Wav"
                                    FileDialogMultiselect="True"
									FileDialogDialogResultCommand="{Binding MainWindowGuiData.WavFilePath, Mode=TwoWay}"
                                    FileDialogDialogResultCommands="{Binding MainWindowGuiData.WavFilesPath, Mode=TwoWay}"
                            />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Button>

            <Button ToolTip="Start Speech Recognition" Command="{Binding DoStartSpeechRecognition}" Margin="2">
                <StackPanel HorizontalAlignment="Center" Margin="1">
                    <Image Source="Images/speech_recognition.png" Width="32" Height="32" HorizontalAlignment="Center" />
                    <TextBlock Text="Recognize" HorizontalAlignment="Center" />
                </StackPanel>
            </Button>

            <Separator />

            <Button ToolTip="Save" Command="{Binding DoSaveChanges}" Margin="2">
                <StackPanel HorizontalAlignment="Center" Margin="1">
                    <Image Source="Images/save.png" Width="32" Height="32" HorizontalAlignment="Center" />
                    <TextBlock Text="Save" HorizontalAlignment="Center" />
                </StackPanel>
            </Button>

            <Separator />

            <Button ToolTip="Convert To UTF-8" Margin="2" Command="{Binding DoConvertToUTF8}">
				<StackPanel HorizontalAlignment="Center" Margin="1">
					<Image Source="Images/format.png" Width="32" Height="32" HorizontalAlignment="Center" />
					<TextBlock Text="To UTF-8" HorizontalAlignment="Center" />
                    <Ctrls:BetterPopup VerticalAlignment="Top" AllowsTransparency="True" 
						   StaysOpen="True"
						   IsOpen="{Binding MainWindowGuiData.PopupDoDetectEncodingIsOpen}"
						   IsTopmost="False"
						   PopupAnimation="Slide" Margin="5">
                        <Border Background="Gray" 
								BorderThickness="2" CornerRadius="6" BorderBrush="Black">
                            <Views:DetectEncodingView FilePath="{Binding MainWindowGuiData.OpenedFilePath}" />
                        </Border>
                    </Ctrls:BetterPopup>
                </StackPanel>
			</Button>

            <Button ToolTip="Insert RLE (U+202B/RIGHT-TO-LEFT EMBEDDING) Unicode character." 
                    Command="{Binding DoInsertRLE}" Margin="2">
                <StackPanel HorizontalAlignment="Center" Margin="1">
                    <Image Source="Images/format_text_direction_rtl.png" Width="32" Height="32" HorizontalAlignment="Center" />
                    <TextBlock Text="Insert RLE" HorizontalAlignment="Center" />
                </StackPanel>
            </Button>

            <Separator />

			<Button Margin="2" Command="{Binding DoSync}"
					ToolTip="Shift all times">
				<StackPanel HorizontalAlignment="Center" Margin="1">
					<Image Source="Images/sync.png" Width="32" Height="32" HorizontalAlignment="Center" />
					<TextBlock Text="Synchronize" HorizontalAlignment="Center" />
					<Ctrls:BetterPopup VerticalAlignment="Top" AllowsTransparency="True" 
						   StaysOpen="True"
						   IsOpen="{Binding MainWindowGuiData.PopupDoSyncIsOpen}"
						   IsTopmost="False"
						   PopupAnimation="Slide" Margin="5">
						<Border Background="Gray" 
								BorderThickness="2" CornerRadius="6" BorderBrush="Black">
							<Views:SyncView  FilePath="{Binding MainWindowGuiData.OpenedFilePath}" />
						</Border>
					</Ctrls:BetterPopup>
				</StackPanel>
			</Button>

			<Button Margin="2" 
					IsEnabled="{Binding MainWindowGuiData.DoMergeIsEnabled}"
					ToolTip="Replace all times of the opened file by times of a selected file">
				<StackPanel HorizontalAlignment="Center" Margin="1">
					<Image Source="Images/join.png" Width="32" Height="32" HorizontalAlignment="Center" />
					<TextBlock Text="Merge Times" HorizontalAlignment="Center" />
				</StackPanel>
				<i:Interaction.Triggers>
					<i:EventTrigger EventName="Click">
						<b:OpenFileDialogBoxBehavior 
									DialogFilterType="Subtitle"
									FileDialogDialogResultCommand="{Binding MainWindowGuiData.MergeFilePath, Mode=TwoWay}"/>
					</i:EventTrigger>
				</i:Interaction.Triggers>                
			</Button>

			<Button Margin="2" Command="{Binding DoJoinFiles}"
					ToolTip="Combine the opened file with a selected file">
				<StackPanel HorizontalAlignment="Center" Margin="1">
					<Image Source="Images/merge.png" Width="32" Height="32" HorizontalAlignment="Center" />
					<TextBlock Text="Join Files" HorizontalAlignment="Center" />
					<Ctrls:BetterPopup VerticalAlignment="Top" AllowsTransparency="True" 
						   StaysOpen="True"                           
						   IsTopmost="False"
						   IsOpen="{Binding MainWindowGuiData.PopupDoJoinFilesIsOpen}"
						   PopupAnimation="Slide" Margin="5">
						<Border Background="Gray" Width="300" 
								BorderThickness="2" CornerRadius="6" BorderBrush="Black">
							<Views:JoinTwoFiles  FirstFilePath="{Binding MainWindowGuiData.OpenedFilePath}" />
						</Border>
					</Ctrls:BetterPopup>
				</StackPanel>
			</Button>

            <Button Margin="2" 
					IsEnabled="{Binding MainWindowGuiData.DoMixIsEnabled}"
					ToolTip="Combine all dialogs of the opened file with dialogs of a selected file">
                <StackPanel HorizontalAlignment="Center" Margin="1">
                    <Image Source="Images/books.png" Width="32" Height="32" HorizontalAlignment="Center" />
                    <TextBlock Text="Mix Dialogs" HorizontalAlignment="Center" />
                </StackPanel>
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <b:OpenFileDialogBoxBehavior 
									DialogFilterType="Subtitle"
									FileDialogDialogResultCommand="{Binding MainWindowGuiData.MixFilePath, Mode=TwoWay}"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Button>

            <Separator />

			<Button Margin="2" Command="{Binding DoDelete}"
					ToolTip="Delete selected row of the subtitle.">
				<StackPanel HorizontalAlignment="Center" Margin="1">
					<Image Source="Images/delete.png" Width="32" Height="32" HorizontalAlignment="Center" />
					<TextBlock Text="Delete Row" HorizontalAlignment="Center" />
				</StackPanel>
			</Button>

            <Button Margin="2" Command="{Binding DoRecalculate}"
					ToolTip="Recalculate row numbers.">
                <StackPanel HorizontalAlignment="Center" Margin="1">
                    <Image Source="Images/calculator.png" Width="32" Height="32" HorizontalAlignment="Center" />
                    <TextBlock Text="Recalculate" HorizontalAlignment="Center" />
                </StackPanel>
            </Button>

            <Separator/>

            <Button ToolTip="Translator" Margin="2" Command="{Binding DoTranslate}">
                <StackPanel HorizontalAlignment="Center" Margin="1">
                    <Image Source="Images/translate.png" Width="32" Height="32" HorizontalAlignment="Center" />
                    <TextBlock Text="Translator" HorizontalAlignment="Center" />
                    <Ctrls:BetterPopup VerticalAlignment="Top" AllowsTransparency="True" 
						   StaysOpen="True"
						   IsOpen="{Binding MainWindowGuiData.TranslatorIsOpen}"
						   IsTopmost="False"
						   PopupAnimation="Slide" Margin="5">
                        <Border Background="Gray" 
								BorderThickness="2" CornerRadius="6" BorderBrush="Black">
                            <Views:TranslatorView FilePath="{Binding MainWindowGuiData.OpenedFilePath}" />
                        </Border>
                    </Ctrls:BetterPopup>
                </StackPanel>
            </Button>
        </ToolBar>
	</Grid>
</UserControl>
